import uiautomation

# 获取当前激活窗口对应的对象：
res = uiautomation.GetForegroundControl().GetTopLevelControl()
print(res)
print(res.Name)
# 获取屏幕分辨率
rects = uiautomation.GetMonitorsRect()
print(rects)
print(rects[-1].left)
print(rects[-1].top)
print(rects[-1].width())
print(rects[-1].height())
exit()
# 获取当前鼠标位置对应的窗口：
res = uiautomation.ControlFromCursor().GetTopLevelControl()
print(res)
# 鼠标点击指定坐标
uiautomation.Click(400, 500)
# 鼠标右键单价
uiautomation.RightClick(400, 800)
# 鼠标拖拽(鼠标从(x1,y1)位置按下鼠标拖动到(x2,y2)位置)：
uiautomation.DragDrop(500, 500, 700, 700, moveSpeed=1)
# 获取运行当前python程序的控制台窗口对象：
res = uiautomation.GetConsoleWindow()
print(res)
# 隐式等待
uiautomation.uiautomation.TIME_OUT_SECOND = 10
# 日志信息
uiautomation.Logger.ColorfullyWrite(log='运行"<Color=Cyan>automation.py -h</Color>"显示帮助\n\n', consoleColor=12, logFile='./log.log')
# 查看搜索控件所遍历的控件数和搜索时间.
uiautomation.uiautomation.DEBUG_SEARCH_TIME = True
# 显示桌面；
uiautomation.ShowDesktop()
